package net.loststone.slurper

import grails.test.*
import net.loststone.*;

class InfojobsSlurperServiceTests extends GrailsUnitTestCase {

    def slurper;

    protected void setUp() {
        super.setUp()

        def manager = new org.apache.commons.httpclient.SimpleHttpConnectionManager(true);
        slurper = new InfojobsSlurperService();
        slurper.connectionManager = manager;
    }

    protected void tearDown() {
        super.tearDown()
    }

//    void testSlurperShouldConnectAndReturnValidJobs() {
//        Town town = Town.findByName("Barcelona");
//        def jobs = slurper.slurp(town.id, "Java");
//        assertNotNull(jobs);
//        assertNotNull(jobs[0].name);
//        assertNotNull(jobs[0].location);
//        assertNotNull(jobs[0].description);
//        assertNotNull(jobs[0].link);
//        assertEquals("infojobs", jobs[0].site);
//    }

    void testSlurperShouldReturnSalaryIfAvailable() {
        def job = slurper.slurpJob(client, "http://www.infojobs.net/barcelona/programador-assem-c-pascal-visual-java-vall-s-or/of-i008544341394105374106371818313");
        assertNotNull(job);
        assertNotNull(job[0].salary);
    }
    
}
